|
OpenStack Liberty : How to use Heat
2015/12/28 |
|
How to use the OpenStack Orchestration Service (Heat).
This example is based on the environment like follows.
|
+------------------+ | +------------------------+
| [ Control Node ] | | | [ Network Node ] |
| Keystone |10.0.0.30 | 10.0.0.50| DHCP,L3,L2 Agent |
| Glance |------------+------------| Metadata Agent |
| Nova API |eth0 | eth0| Heat API,API-CFN |
| Neutron Server | | | Heat Engine |
+------------------+ | +------------------------+
eth0|10.0.0.51
+--------------------+
| [ Compute Node ] |
| Nova Compute |
| L2 Agent |
+--------------------+
|
| [1] | Deploy Instances with Heat services and templates. The example below is on the Controle Node. |
heat_template_version: 2015-10-15
description: Heat Sample Template
parameters:
ImageID:
type: string
description: Image used to boot a server
NetID:
type: string
description: Network ID for the server
resources:
server1:
type: OS::Nova::Server
properties:
name: "Heat_Deployed_Server"
image: { get_param: ImageID }
flavor: "m1.small"
networks:
- network: { get_param: NetID }
outputs:
server1_private_ip:
description: IP address of the server in the private network
value: { get_attr: [ server1, first_address ] }
root@dlp ~(keystone)#
glance image-list +--------------------------------------+------------+ | ID | Name | +--------------------------------------+------------+ | f29a589b-595a-4f0c-bbce-f6f3537f2a7c | Ubuntu1404 | +--------------------------------------+------------+root@dlp ~(keystone)# neutron net-list +--------------------------------------+---------+-------------------------------------------------------+ | id | name | subnets | +--------------------------------------+---------+-------------------------------------------------------+ | f1c05750-2dbe-4e9e-9b56-ca4107f54160 | ext_net | 30dee5b0-0504-4575-be0e-455ac25a68d4 10.0.0.0/24 | | c352c783-37d5-40c4-8e50-0d0d6e44fa21 | int_net | 7e3e5878-b69b-427c-b24d-ac9cbdf284ce 192.168.100.0/24 | +--------------------------------------+---------+-------------------------------------------------------+root@dlp ~(keystone)# Int_Net_ID=`neutron net-list | grep int_net | awk '{ print $2 }'`
# create an instance from the template root@dlp ~(keystone)# heat stack-create -f sample-stack.yml -P "ImageID=Ubuntu1404;NetID=$Int_Net_ID" Sample-Stack +--------------------------------------+--------------+--------------------+---------------------+--------------+ | id | stack_name | stack_status | creation_time | updated_time | +--------------------------------------+--------------+--------------------+---------------------+--------------+ | 4f2e06f2-428c-4c62-96da-a43cfbf030dc | Sample-Stack | CREATE_IN_PROGRESS | 2016-01-03T12:07:46 | None | +--------------------------------------+--------------+--------------------+---------------------+--------------+ # turn to "CREATE_COMPLETE" after few minutes later like follows root@dlp ~(keystone)# heat stack-list +--------------------------------------+--------------+-----------------+---------------------+--------------+ | id | stack_name | stack_status | creation_time | updated_time | +--------------------------------------+--------------+-----------------+---------------------+--------------+ | 4f2e06f2-428c-4c62-96da-a43cfbf030dc | Sample-Stack | CREATE_COMPLETE | 2016-01-03T12:07:46 | None | +--------------------------------------+--------------+-----------------+---------------------+--------------+ # the instance is running which is created from the Heat template root@dlp ~(keystone)# nova list +-----------+----------------------+---------+------------+-------------+-----------------------------------+ | ID | Name | Status | Task State | Power State | Networks | +-----------+----------------------+---------+------------+-------------+-----------------------------------+ | 3ae2b32c- | Heat_Deployed_Server | ACTIVE | - | Running | int_net=192.168.100.4 | | a25ba5e7- | Ubuntu_1404 | SHUTOFF | - | Shutdown | int_net=192.168.100.3, 10.0.0.201 | +-----------+----------------------+---------+------------+-------------+-----------------------------------+ # delete the instance like follows if you don't need root@dlp ~(keystone)# heat stack-delete Sample-Stack +--------------------------------------+--------------+-----------------+---------------------+--------------+ | id | stack_name | stack_status | creation_time | updated_time | +--------------------------------------+--------------+-----------------+---------------------+--------------+ | 4f2e06f2-428c-4c62-96da-a43cfbf030dc | Sample-Stack | CREATE_COMPLETE | 2016-01-03T12:07:46 | None | +--------------------------------------+--------------+-----------------+---------------------+--------------+root@dlp ~(keystone)# heat stack-list +----+------------+--------------+---------------+ | id | stack_name | stack_status | creation_time | +----+------------+--------------+---------------+ +----+------------+--------------+---------------+ |
| [2] |
The guide for writing templates are opened on the official site below.
⇒ http://docs.openstack.org/developer/heat/template_guide/index.html |